package com.scalar.forecast.forecastSetup.actions;

import com.scalar.forecast.ForecastExtendedAction;
import com.scalar.forecast.forecastSetup.actionCommands.ForecastUserFieldsActionCommandFactory;
import com.scalar.forecast.actionCommands.ActionCommand;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;

/**
 * User: Sujan Kumar
 * Date: Feb 7, 2005
 * Time: 8:29:33 PM
 */
public class ForecastUserDefinedFieldsAction  extends ForecastExtendedAction
{
    public ActionForward executeRequest ( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ) throws  ServletException, IOException
    {
        ActionForward actionForward = mapping.findForward("success");
        String action = request.getParameter("action");
        try
        {
            if ( action == null )
            {
                action = ACTION_NEW;
            }
            ActionCommand actionCommand = ForecastUserFieldsActionCommandFactory.getActionCommand( action );
            if ( actionCommand != null)
            {
                actionForward = actionCommand.execute( mapping, form, request, response );
            }

        }
        catch ( Exception e )
        {
            e.printStackTrace();
        }
        return mapping.findForward ( "success" );
    }
}
